/*
 * Quarter.h
 *
 *  Created on: 06-Sep-2014
 *      Author: ali
 */

#ifndef QUARTER_H_
#define QUARTER_H_

#include "Coordinate.h"
#include "Level.h"
#include <iostream>
using namespace std;

class Quarter
{
	int m_nID;
	double m_dLen;
	double m_dWidth;
	Coordinate m_cMyPos;
	std::vector<int> m_vectorSensor;
	std::vector<Node> m_vectorSink;
	Level m_acL[3]; // 0 top 1 -mid 2 -low
	int m_iIndexofCH0;

public:

	Coordinate GetPos();
	Coordinate GetMid()
	{
		Coordinate mid((m_cMyPos.GetXPos() + GetLen() / 2),
				m_cMyPos.GetYPos() + GetWidth() / 2);
		return mid;
	}

	double GetLen()
	{
		return m_dLen;
	}
	double GetWidth()
	{
		return m_dWidth;
	}
	int GetID();

	Quarter();
	Quarter(int id, double len, double width, const Coordinate& pos);
	void InitLevel();
	bool IsCoordinateInside(Coordinate otherPos);
	void AddSensor(Node &node);
	void AddSink(Node &node);
	Node GetSink();
	Node& GetSinkByRef();
	int GetSinkID();
	bool SelectCH();
	bool SendData();

	friend ostream & operator<<(ostream &out, Quarter& q);
	~Quarter();
};

#endif /* QUARTER_H_ */
